package org.ing.sisval.gui.control;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.ing.sisval.be.BELado;
import org.ing.sisval.be.BETerreno;
import org.ing.sisval.bl.BLLado;
import org.ing.sisval.bl.BLTerreno;
import org.ing.sisval.gui.JFPrincipal;
import org.ing.sisval.gui.control.model.ModeloLado;
import org.rx.cr.gui.DesktopPanel;
import org.rx.cr.gui.JInternalFrameUC;
import org.rx.cr.util.Utilitarios;
import static org.rx.cr.util.Utilitarios.addCharacterValidatorEvent;
import static org.rx.cr.util.Utilitarios.disableComponent;
import static org.rx.cr.util.Utilitarios.enableComponent;
import static org.rx.cr.util.Utilitarios.isDatosLlenos;
import static org.rx.cr.util.Utilitarios.resetComponents;

public class JIFValuacionTerreno extends JInternalFrameUC {

    JFPrincipal parent;
    BETerreno be;
    BLTerreno bl;

    ModeloLado modeloLado;
    BELado beLado;
    BLLado blLado;

    //JIFValuacionPropiedad jifValuacionPropiedad;
    public DesktopPanel dp;

    public JIFValuacionTerreno(JFPrincipal parent) {
        initComponents();
        this.parent = parent;
        dp = new DesktopPanel();
        dp.setDesktopBackground("/org/ing/sisval/imagen/Curso.png");

        modeloLado = new ModeloLado();

        bl = new BLTerreno(parent.getConf());
        blLado = new BLLado(parent.getConf());

        _init();

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSeparator5 = new javax.swing.JSeparator();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jcbTipoTerreno = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jcbCaracteristicaTerreno = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        txfAncho = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txfLargo = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txfAreaLote = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txfValorUnitario = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        txfNumLados = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtLado = new javax.swing.JTable();
        txfValorTerreno = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jbSalir = new javax.swing.JButton();
        jbAgregar = new javax.swing.JButton();
        jbGuardar = new javax.swing.JButton();
        jbCancelar = new javax.swing.JButton();
        jbCalcularValorTotal = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        txfAnchoPasadizo = new javax.swing.JTextField();
        txfDistancia = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jlAnchoPasadizo = new javax.swing.JLabel();
        jlDistancia = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        txfLargoPasaje = new javax.swing.JTextField();
        txfAnchoPasaje = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jlAnchoPasaje = new javax.swing.JLabel();
        jlLargoPasaje = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        txfAnchoDominio = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        txfLargoDominio = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        txfCoeficiente = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jlAnchoDominio = new javax.swing.JLabel();
        jlLargoDominio = new javax.swing.JLabel();
        jlCoeficiente = new javax.swing.JLabel();
        jcbTipoValuacion = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        txfPorcentajeDerecho = new javax.swing.JTextField();
        jcbConsiderar = new javax.swing.JCheckBox();
        jlImagen = new javax.swing.JLabel();
        jlAncho = new javax.swing.JLabel();
        jlLargo = new javax.swing.JLabel();
        jlArea = new javax.swing.JLabel();
        jlValorUnitario = new javax.swing.JLabel();

        jSeparator5.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos del lote"));

        setClosable(true);
        setIconifiable(true);
        setTitle("VALUACIÓN DE TERRENO");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "VALUACIÓN DE TERRENO", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        jLabel1.setText("Tipo de lote :");

        jcbTipoTerreno.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<Seleccionar>", "Con un solo frente a la via publica", "Con mas de un frente a la via publica", "Con frente a un pasadizo comun o via de dominio privado en condominio", "Sin acceso por via publica ni privada sino por predio de propiedad de terceros", "Restriccion de uso que soporte un predio, derivado de la servidumbre a favor de terceros.", "Lote con frente inferior al normativo vigente", "Lote con profundidad menor de quince metros", "Situado parte en tierra firme y parte en mar" }));
        jcbTipoTerreno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbTipoTerrenoActionPerformed(evt);
            }
        });

        jLabel2.setText("Característica del lote :");

        jcbCaracteristicaTerreno.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<Seleccionar>", "Rectangular", "Irregular" }));
        jcbCaracteristicaTerreno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbCaracteristicaTerrenoActionPerformed(evt);
            }
        });

        jLabel3.setText("Ancho (m) :");

        txfAncho.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txfAnchoActionPerformed(evt);
            }
        });

        jLabel4.setText("Largo (m) :");

        jLabel5.setText("Area de lote (m²) :");

        txfAreaLote.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txfAreaLoteActionPerformed(evt);
            }
        });

        jLabel6.setText("Valor unitario (s/m²) :");

        txfValorUnitario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txfValorUnitarioActionPerformed(evt);
            }
        });

        jLabel7.setText("Número de lados :");

        txfNumLados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txfNumLadosActionPerformed(evt);
            }
        });
        txfNumLados.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txfNumLadosKeyTyped(evt);
            }
        });

        jtLado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Title 1", "Title 2"
            }
        ));
        jScrollPane2.setViewportView(jtLado);

        txfValorTerreno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txfValorTerrenoActionPerformed(evt);
            }
        });

        jLabel16.setText("Valor total (S/.):");

        jbSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/exit_min.png"))); // NOI18N
        jbSalir.setText("SALIR");
        jbSalir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbSalir.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jbSalir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbSalirActionPerformed(evt);
            }
        });

        jbAgregar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/Nuevo.png"))); // NOI18N
        jbAgregar.setText("AGREGAR");
        jbAgregar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbAgregar.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jbAgregar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbAgregarActionPerformed(evt);
            }
        });

        jbGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/Guardar_Min.png"))); // NOI18N
        jbGuardar.setText("GUARDAR");
        jbGuardar.setEnabled(false);
        jbGuardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbGuardar.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jbGuardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbGuardarActionPerformed(evt);
            }
        });

        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/Cancelar_Min.png"))); // NOI18N
        jbCancelar.setText("CANCELAR");
        jbCancelar.setEnabled(false);
        jbCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbCancelar.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jbCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        jbCalcularValorTotal.setText("Calcular");
        jbCalcularValorTotal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCalcularValorTotalActionPerformed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATOS DEL PASADIZO", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        txfAnchoPasadizo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txfAnchoPasadizoActionPerformed(evt);
            }
        });

        jLabel9.setText("Distancia (m) :");

        jLabel8.setText("Ancho del pasadizo (m) :");

        jlAnchoPasadizo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlAnchoPasadizo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jlDistancia.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlDistancia.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel9)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txfAnchoPasadizo, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
                    .addComponent(txfDistancia))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jlAnchoPasadizo, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jlDistancia, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel8)
                        .addComponent(txfAnchoPasadizo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jlAnchoPasadizo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel9)
                        .addComponent(txfDistancia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jlDistancia, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, 0))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATOS DEL PASAJE", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        jLabel13.setText("Largo del pasaje (m) :");

        jLabel12.setText("Ancho del pasaje (m) :");

        jlAnchoPasaje.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlAnchoPasaje.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jlLargoPasaje.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlLargoPasaje.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txfLargoPasaje, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                    .addComponent(txfAnchoPasaje))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jlAnchoPasaje, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jlLargoPasaje, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(1, 1, 1)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jlAnchoPasaje, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlLargoPasaje, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(txfAnchoPasaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel13)
                            .addComponent(txfLargoPasaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATOS DEL DOMINIO", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        jLabel10.setText("Ancho del dominio (m) :");

        jLabel11.setText("Largo del dominio (m) :");

        jLabel14.setText("Coeficiente α (0.99 - 0.9) :");

        jlAnchoDominio.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlAnchoDominio.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jlLargoDominio.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlLargoDominio.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jlCoeficiente.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlCoeficiente.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txfLargoDominio, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txfCoeficiente)
                    .addComponent(txfAnchoDominio, javax.swing.GroupLayout.Alignment.LEADING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jlAnchoDominio, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jlCoeficiente, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jlLargoDominio, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, 0))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txfAnchoDominio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txfLargoDominio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txfCoeficiente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jlAnchoDominio, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(25, 25, 25))
                    .addComponent(jlLargoDominio, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jlCoeficiente, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jcbTipoValuacion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<Seleccionar>", "Comercial", "Reglamentaria" }));
        jcbTipoValuacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbTipoValuacionActionPerformed(evt);
            }
        });

        jLabel15.setText("Tipo de valuación :");

        jLabel17.setText("Porcentaje de derecho (%) :");

        jcbConsiderar.setText("Considerar");
        jcbConsiderar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbConsiderarActionPerformed(evt);
            }
        });
        jcbConsiderar.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jcbConsiderarPropertyChange(evt);
            }
        });

        jlImagen.setBackground(new java.awt.Color(255, 255, 255));
        jlImagen.setForeground(new java.awt.Color(255, 255, 255));
        jlImagen.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jlImagen.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jlAncho.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlAncho.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jlLargo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlLargo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jlArea.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlArea.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jlValorUnitario.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlValorUnitario.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel15)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel7))
                .addGap(4, 4, 4)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jcbCaracteristicaTerreno, 0, 221, Short.MAX_VALUE)
                            .addComponent(jlImagen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                            .addComponent(txfNumLados)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txfAncho)
                                    .addComponent(txfAreaLote)
                                    .addComponent(txfLargo, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jlAncho, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jlLargo, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jlArea, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel17, javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.TRAILING))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(txfValorUnitario)
                                            .addComponent(txfValorTerreno)
                                            .addComponent(txfPorcentajeDerecho, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jcbConsiderar)
                                            .addComponent(jbCalcularValorTotal)
                                            .addComponent(jlValorUnitario, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(60, 60, 60)
                                        .addComponent(jbAgregar)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jbGuardar)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jbCancelar)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jbSalir))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
                    .addComponent(jcbTipoValuacion, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jcbTipoTerreno, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(jcbTipoValuacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jcbTipoTerreno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcbCaracteristicaTerreno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(txfValorUnitario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel6))
                            .addComponent(jlValorUnitario, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel17)
                            .addComponent(txfPorcentajeDerecho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jcbConsiderar))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txfValorTerreno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel16)
                            .addComponent(jbCalcularValorTotal))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jbCancelar, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jbSalir)
                                .addComponent(jbAgregar)
                                .addComponent(jbGuardar)))
                        .addGap(0, 10, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jlImagen, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(txfAncho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jlAncho, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel3))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(txfLargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel4)))
                                    .addComponent(jlLargo, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txfAreaLote, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5)))
                            .addComponent(jlArea, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txfNumLados, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 756, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txfAreaLoteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txfAreaLoteActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txfAreaLoteActionPerformed

    private void txfAnchoPasadizoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txfAnchoPasadizoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txfAnchoPasadizoActionPerformed

    private void jcbCaracteristicaTerrenoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbCaracteristicaTerrenoActionPerformed
        // TODO add your handling code here:

        if (_OPERACION != _DESCONOCIDO) {
            switch (jcbCaracteristicaTerreno.getSelectedIndex()) {
                case 1: //rectangular
                    txfAncho.setEnabled(true);
                    txfLargo.setEnabled(true);
                    txfAreaLote.setEnabled(false);

                    break;
                case 2: //irregular
                    txfAncho.setEnabled(false);
                    txfLargo.setEnabled(false);
                    txfAreaLote.setEnabled(true);

                    break;
            }
        }
    }//GEN-LAST:event_jcbCaracteristicaTerrenoActionPerformed

    private void jbSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbSalirActionPerformed
        // TODO add your handling code here:
        dispose();
    }//GEN-LAST:event_jbSalirActionPerformed

    private void jcbTipoTerrenoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbTipoTerrenoActionPerformed
        // TODO add your handling code here:
        //modeloLado.clear();
        clear();
        jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_default.png")));
        clear();
        if (_OPERACION != _DESCONOCIDO) {
            switch (jcbTipoTerreno.getSelectedIndex()) {
                case 1: // un solo frente

                    jcbCaracteristicaTerreno.setEnabled(true);
                    txfAncho.setEnabled(false);
                    txfLargo.setEnabled(false);

                    txfValorUnitario.setEnabled(true);
                    jbCalcularValorTotal.setEnabled(true);

                    txfNumLados.setEnabled(false);
                    txfAnchoPasadizo.setEnabled(false);
                    txfDistancia.setEnabled(false);
                    txfAnchoPasaje.setEnabled(false);
                    txfLargoPasaje.setEnabled(false);
                    txfAnchoDominio.setEnabled(false);
                    txfLargoDominio.setEnabled(false);
                    txfCoeficiente.setEnabled(false);
                    txfAreaLote.setEnabled(false);

                    jtLado.setEnabled(false);
                    jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_solo_frente.png")));
                    jlAncho.setText("a");
                    jlLargo.setText("b");
                    jlAnchoDominio.setText("");
                    jlAnchoPasadizo.setText("");
                    jlAnchoPasaje.setText("");
                    jlArea.setText("");
                    jlCoeficiente.setText("");
                    jlDistancia.setText("");
                    jlLargoPasaje.setText("");
                    jlLargoDominio.setText("");
                    jlValorUnitario.setText("vu");
                    jtLado.setOpaque(true);

                    break;
                case 2: // mas de un frente

                    txfNumLados.setEnabled(true);
                    jtLado.setEnabled(true);
                    jbCalcularValorTotal.setEnabled(true);
                    txfAreaLote.setEnabled(true);

                    jcbCaracteristicaTerreno.setEnabled(false);
                    txfAncho.setEnabled(false);
                    txfLargo.setEnabled(false);

                    txfValorUnitario.setEnabled(false);
                    txfAnchoPasadizo.setEnabled(false);
                    txfDistancia.setEnabled(false);
                    txfAnchoPasaje.setEnabled(false);
                    txfLargoPasaje.setEnabled(false);
                    txfAnchoDominio.setEnabled(false);
                    txfLargoDominio.setEnabled(false);
                    txfCoeficiente.setEnabled(false);
                    jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_mas_frente.png")));
                    jlAncho.setText("");
                    jlLargo.setText("");
                    jlAnchoDominio.setText("");
                    jlAnchoPasadizo.setText("");
                    jlAnchoPasaje.setText("");
                    jlArea.setText("S");
                    jlCoeficiente.setText("");
                    jlDistancia.setText("");
                    jlLargoPasaje.setText("");
                    jlLargoDominio.setText("");
                    jlValorUnitario.setText("");
                    jtLado.setOpaque(false);

                    break;
                case 3:// frente a un pasadizo

                    txfAncho.setEnabled(true);
                    txfLargo.setEnabled(true);
                    txfAnchoPasadizo.setEnabled(true);
                    txfDistancia.setEnabled(true);
                    txfAnchoDominio.setEnabled(true);
                    txfLargoDominio.setEnabled(true);
                    txfValorUnitario.setEnabled(true);

                    jbCalcularValorTotal.setEnabled(true);

                    jcbCaracteristicaTerreno.setEnabled(false);
                    txfAreaLote.setEnabled(false);
                    txfNumLados.setEnabled(false);
                    txfAnchoPasaje.setEnabled(false);
                    txfLargoPasaje.setEnabled(false);
                    txfCoeficiente.setEnabled(false);
                    jtLado.setEnabled(false);
                    jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_frente_pasadizo.png")));
                    jlAncho.setText("x");
                    jlLargo.setText("y");
                    jlAnchoDominio.setText("b");
                    jlAnchoPasadizo.setText("a");
                    jlAnchoPasaje.setText("");
                    jlArea.setText("");
                    jlCoeficiente.setText("");
                    jlDistancia.setText("d");
                    jlLargoPasaje.setText("");
                    jlLargoDominio.setText("c");
                    jlValorUnitario.setText("VAU");
                    jtLado.setOpaque(true);

                    break;
                case 4://sin acceso por via publica

                    txfAncho.setEnabled(true);
                    txfLargo.setEnabled(true);
                    txfAnchoPasaje.setEnabled(true);
                    txfLargoPasaje.setEnabled(true);
                    txfValorUnitario.setEnabled(true);
                    jbCalcularValorTotal.setEnabled(true);

                    txfAreaLote.setEnabled(false);
                    jcbCaracteristicaTerreno.setEnabled(false);
                    txfNumLados.setEnabled(false);
                    txfAnchoPasadizo.setEnabled(false);
                    txfDistancia.setEnabled(false);
                    txfAnchoDominio.setEnabled(false);
                    txfLargoDominio.setEnabled(false);
                    txfCoeficiente.setEnabled(false);
                    jtLado.setEnabled(false);
                    jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_sin_acceso.png")));
                    jlAncho.setText("x");
                    jlLargo.setText("b");
                    jlAnchoDominio.setText("");
                    jlAnchoPasadizo.setText("");
                    jlAnchoPasaje.setText("a");
                    jlArea.setText("");
                    jlCoeficiente.setText("");
                    jlDistancia.setText("");
                    jlLargoPasaje.setText("d");
                    jlLargoDominio.setText("");
                    jlValorUnitario.setText("VT");
                    jtLado.setOpaque(true);

                    break;
                case 5:// restriccion de uso
                    txfAncho.setEnabled(true);
                    txfLargo.setEnabled(true);
                    txfValorUnitario.setEnabled(true);
                    txfCoeficiente.setEnabled(true);
                    jbCalcularValorTotal.setEnabled(true);

                    txfAreaLote.setEnabled(false);
                    jcbCaracteristicaTerreno.setEnabled(false);
                    txfAnchoPasaje.setEnabled(false);
                    txfLargoPasaje.setEnabled(false);
                    txfNumLados.setEnabled(false);
                    txfAnchoPasadizo.setEnabled(false);
                    txfDistancia.setEnabled(false);
                    txfAnchoDominio.setEnabled(false);
                    txfLargoDominio.setEnabled(false);
                    jtLado.setEnabled(false);
                    jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_restriccion_uso.png")));
                    jlAncho.setText("b");
                    jlLargo.setText("d");
                    jlAnchoDominio.setText("");
                    jlAnchoPasadizo.setText("");
                    jlAnchoPasaje.setText("");
                    jlArea.setText("");
                    jlCoeficiente.setText("");
                    jlDistancia.setText("");
                    jlLargoPasaje.setText("");
                    jlLargoDominio.setText("");
                    jlValorUnitario.setText("VT");
                    jtLado.setOpaque(true);
                    break;

                case 6://lote con frente inferiornormativo
                    txfAncho.setEnabled(true);
                    txfLargo.setEnabled(true);
                    txfValorUnitario.setEnabled(true);
                    jbCalcularValorTotal.setEnabled(true);

                    txfCoeficiente.setEnabled(false);
                    txfAreaLote.setEnabled(false);
                    jcbCaracteristicaTerreno.setEnabled(false);
                    txfAnchoPasaje.setEnabled(false);
                    txfLargoPasaje.setEnabled(false);
                    txfNumLados.setEnabled(false);
                    txfAnchoPasadizo.setEnabled(false);
                    txfDistancia.setEnabled(false);
                    txfAnchoDominio.setEnabled(false);
                    txfLargoDominio.setEnabled(false);
                    jtLado.setEnabled(false);
                    jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_normativo_vigente.png")));
                    jlAncho.setText("a");
                    jlLargo.setText("b");
                    jlAnchoDominio.setText("");
                    jlAnchoPasadizo.setText("");
                    jlAnchoPasaje.setText("");
                    jlArea.setText("");
                    jlCoeficiente.setText("");
                    jlDistancia.setText("");
                    jlLargoPasaje.setText("");
                    jlLargoDominio.setText("");
                    jlValorUnitario.setText("VT");
                    jtLado.setOpaque(true);

                    break;
                case 7:// lote con profundidad
                    txfAncho.setEnabled(true);
                    txfLargo.setEnabled(true);
                    txfValorUnitario.setEnabled(true);
                    jbCalcularValorTotal.setEnabled(true);

                    txfCoeficiente.setEnabled(false);
                    txfAreaLote.setEnabled(false);
                    jcbCaracteristicaTerreno.setEnabled(false);
                    txfAnchoPasaje.setEnabled(false);
                    txfLargoPasaje.setEnabled(false);
                    txfNumLados.setEnabled(false);
                    txfAnchoPasadizo.setEnabled(false);
                    txfDistancia.setEnabled(false);
                    txfAnchoDominio.setEnabled(false);
                    txfLargoDominio.setEnabled(false);
                    jtLado.setEnabled(false);
                    jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_inferior_15.png")));
                    jlAncho.setText("a");
                    jlLargo.setText("b");
                    jlAnchoDominio.setText("");
                    jlAnchoPasadizo.setText("");
                    jlAnchoPasaje.setText("");
                    jlArea.setText("");
                    jlCoeficiente.setText("");
                    jlDistancia.setText("");
                    jlLargoPasaje.setText("");
                    jlLargoDominio.setText("");
                    jlValorUnitario.setText("VT");
                    jtLado.setOpaque(true);

                    break;
                case 8:/// parte en tierra firme
                    txfAncho.setEnabled(true);
                    txfLargo.setEnabled(true);
                    txfValorUnitario.setEnabled(true);
                    jbCalcularValorTotal.setEnabled(true);

                    txfCoeficiente.setEnabled(false);
                    txfAreaLote.setEnabled(false);
                    jcbCaracteristicaTerreno.setEnabled(false);
                    txfAnchoPasaje.setEnabled(false);
                    txfLargoPasaje.setEnabled(false);
                    txfNumLados.setEnabled(false);
                    txfAnchoPasadizo.setEnabled(false);
                    txfDistancia.setEnabled(false);
                    txfAnchoDominio.setEnabled(false);
                    txfLargoDominio.setEnabled(false);
                    jtLado.setEnabled(false);
                    jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_firme_mar.png")));
                    jlAncho.setText("a");
                    jlLargo.setText("b");
                    jlAnchoDominio.setText("");
                    jlAnchoPasadizo.setText("");
                    jlAnchoPasaje.setText("");
                    jlArea.setText("");
                    jlCoeficiente.setText("");
                    jlDistancia.setText("");
                    jlLargoPasaje.setText("");
                    jlLargoDominio.setText("");
                    jlValorUnitario.setText("VT");
                    jtLado.setOpaque(true);

                    break;
            }
        }
    }//GEN-LAST:event_jcbTipoTerrenoActionPerformed

    private void jbCalcularValorTotalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCalcularValorTotalActionPerformed

        try {
            if (_OPERACION != _DESCONOCIDO) {
                switch (jcbTipoValuacion.getSelectedIndex()) {
                    case 1: // comercial
                        double area,
                         valunit;
                        if (!txfAreaLote.getText().isEmpty() && !txfValorUnitario.getText().isEmpty()) {
                            area = Double.parseDouble(txfAreaLote.getText());
                            valunit = Double.parseDouble(txfValorUnitario.getText());
                            if (jcbConsiderar.isSelected()) {
                                double pd = Double.parseDouble(txfPorcentajeDerecho.getText()) / 100;

                                txfValorTerreno.setText(Double.toString(redondear(area * valunit * pd)));
                            } else {
                                txfValorTerreno.setText(Double.toString(redondear(area * valunit)));
                            }

                        } else {
                            JOptionPane.showMessageDialog(this, "Complete todos los campos", "Valorización del terreno", JOptionPane.INFORMATION_MESSAGE);
                        }

                        break;
                    case 2: //reglamentario

                        double a,
                         b,
                         c,
                         d;

                        double r1,
                         r2,
                         SVU = 0,
                         S1,
                         SL,
                         SP,
                         VAPC,
                         SFP,
                         SV1,
                         SPF,
                         SPT;
                        double S = 0,
                         s1 = 0,
                         s2 = 0,
                         VT,
                         vut,
                         x,
                         y,
                         coef;
                        double VT2 = 0;
                        if (_OPERACION != _DESCONOCIDO) {
                            switch (jcbTipoTerreno.getSelectedIndex()) {

                                case 1: // un solo frente
                                    if (_OPERACION != _DESCONOCIDO) {
                                        switch (jcbCaracteristicaTerreno.getSelectedIndex()) {
                                            case 1: //rectangular
                                                if (!txfAncho.getText().isEmpty() && !txfLargo.getText().isEmpty() && !txfValorUnitario.getText().isEmpty()) {
                                                    a = Double.parseDouble(txfAncho.getText());
                                                    b = Double.parseDouble(txfLargo.getText());
                                                    vut = Double.parseDouble(txfValorUnitario.getText());
                                                    System.out.println("entra aqui los valores de " + a);
                                                    System.out.println("entra aqui los valores de " + b);
                                                    System.out.println("entra aqui los valores de " + vut);
                                                    if (a * b > 3 * a * a) {
                                                        VT = redondear((3 * a * a * vut) + (Math.abs((3 * a * a * vut) - (a * b * vut)) / 2));
                                                    } else {
                                                        VT = redondear(a * b * vut);
                                                    }
                                                    txfValorTerreno.setText(Double.toString(VT));
                                                    txfAreaLote.setText(Double.toString(redondear(a * b)));

                                                } else {
                                                    JOptionPane.showMessageDialog(this, "Complete todos los campos", "Valorización del terreno", JOptionPane.INFORMATION_MESSAGE);
                                                }
                                                break;
                                            case 2: //irregular
                                                if (!txfAreaLote.getText().isEmpty() && !txfValorUnitario.getText().isEmpty()) {
                                                    a = Double.parseDouble(txfAreaLote.getText());
                                                    vut = Double.parseDouble(txfValorUnitario.getText());
                                                    System.out.println("entra aqui los valores de area " + a);
                                                    System.out.println("entra aqui los valores de valor unitario " + vut);

                                                    VT = redondear(a * vut);

                                                    txfValorTerreno.setText(Double.toString(VT));

                                                } else {
                                                    JOptionPane.showMessageDialog(this, "Complete todos los campos", "Valorización del terreno", JOptionPane.INFORMATION_MESSAGE);
                                                }
                                                break;
                                        }
                                    }

                                    break;
                                case 2: // mas de un frente

                                    List<Double> listaMedida,
                                     listaValorUnitario,
                                     listaAreaLado,
                                     listaSubtotal,
                                     listaSubtotal1;
                                    List<BELado> listaLado;
                                    Double sumaMedida = 0.0;
                                    if (!txfNumLados.getText().isEmpty() && jtLado.getRowCount() > 0 && !txfAreaLote.getText().isEmpty()) {
                                        double areaTerreno = Double.parseDouble(txfAreaLote.getText());

                                        listaMedida = new ArrayList<>();
                                        listaValorUnitario = new ArrayList<>();
                                        listaLado = new ArrayList<>();
                                        listaAreaLado = new ArrayList<>();//Sa,Sb,Sc...
                                        listaSubtotal = new ArrayList<>();//STa,STb,STc...
                                        listaSubtotal1 = new ArrayList<>();

                                        for (int i = 0; i < jtLado.getRowCount(); i++) {
                                            listaLado.add(modeloLado.get(i));
                                            listaMedida.add(modeloLado.get(i).getMedida());
                                            listaValorUnitario.add(modeloLado.get(i).getValorunitario());
                                            sumaMedida = sumaMedida + modeloLado.get(i).getMedida();
                                        }

                                        for (int i = 0; i < listaMedida.size(); i++) {
                                            listaAreaLado.add(redondear((listaMedida.get(i) / sumaMedida) * areaTerreno));
                                        }
                                        for (int i = 0; i < listaAreaLado.size(); i++) {

                                            if (listaAreaLado.get(i) > 3 * listaMedida.get(i) * listaMedida.get(i)) {
                                                listaSubtotal.add(redondear((2 * 3 * listaMedida.get(i) * listaMedida.get(i)) - (listaAreaLado.get(i) * listaValorUnitario.get(i))));
                                            } else {
                                                listaSubtotal.add(redondear(listaAreaLado.get(i) * listaValorUnitario.get(i)));
                                            }
                                        }
                                        for (int i = 0; i < listaSubtotal.size(); i++) {
                                            VT2 = redondear(VT2 + listaSubtotal.get(i));

                                        }
                                        double arealado = Double.parseDouble(txfAreaLote.getText());

                                        for (int i = 0; i < listaAreaLado.size(); i++) {

                                            if (listaAreaLado.get(i) > 3 * listaMedida.get(i) * listaMedida.get(i)) {
                                                listaSubtotal1.add(redondear((2 * 3 * listaMedida.get(i) * listaMedida.get(i)) - (listaAreaLado.get(i) * listaValorUnitario.get(i))));
                                            } else {
                                                listaSubtotal1.add(redondear(arealado * listaValorUnitario.get(i)));
                                            }
                                        }

                                        for (int i = 0; i < listaSubtotal1.size(); i++) {
                                            if (VT2 <= listaSubtotal1.get(i)) {
                                                VT2 = redondear(listaSubtotal1.get(i));
                                            }
                                        }

                                        txfValorTerreno.setText(Double.toString(VT2));

                                    } else {
                                        JOptionPane.showMessageDialog(this, "Complete todos los campos", "Valor de predio", JOptionPane.INFORMATION_MESSAGE);

                                    }

                                    break;
                                case 3:// frente a un pasadizo

                                    //para calcular el valor del 3
                                    if (!txfAncho.getText().isEmpty() && !txfLargo.getText().isEmpty()
                                            && !txfAnchoPasadizo.getText().isEmpty() && !txfDistancia.getText().isEmpty()
                                            && !txfAnchoDominio.getText().isEmpty() && !txfLargoDominio.getText().isEmpty() && !txfValorUnitario.getText().isEmpty()) {
                                        x = Double.parseDouble(txfAncho.getText());
                                        y = Double.parseDouble(txfLargo.getText());
                                        vut = Double.parseDouble(txfValorUnitario.getText());
                                        a = Double.parseDouble(txfAnchoPasadizo.getText());
                                        d = Double.parseDouble(txfDistancia.getText());
                                        b = Double.parseDouble(txfAnchoDominio.getText());
                                        c = Double.parseDouble(txfLargoDominio.getText());

                                        if ((a / 3) >= 1) {//////////////////

                                            SVU = redondear(vut * (1 - (0.01 * d)));
                                        } else if ((a / 3) < 1) {
                                            SVU = redondear(vut * (a / 3) * (1 - (0.01 * d)));
                                        }
                                        System.out.println("SVU: " + SVU);

                                        if (SVU < 0.5 * vut) {
                                            S1 = redondear(0.5 * vut);//donde se usa?
                                        } else {
                                            S1 = SVU;//donde se usa?
                                        }

                                        System.out.println(" S1 (0.5*vut)" + S1);

                                        //area del lote
                                        if (x * y > 3 * x * x) {
                                            r1 = redondear(3 * x * x * S1);
                                            r2 = redondear((Math.abs(r1 - (x * y * S1))) / 2);
                                            SL = redondear(r1 + r2);
                                        } else {
                                            SL = redondear(x * y * S1);

                                        }
                                        txfAreaLote.setText(Double.toString(SL));
                                        System.out.println("SL (VADE): " + SL);
                                        //area de pasadiso
                                        if (a * (d + x) > 3 * a * a) {
                                            r1 = redondear(3 * a * a * vut);
                                            r2 = redondear((Math.abs((r1) - a * (d + x) * vut)) / 2);
                                            SP = redondear(r1 + r2);
                                            System.out.println("SP: " + SP);
                                        } else {
                                            SP = redondear(a * (d + x) * vut);
                                            System.out.println("SP: " + SP);

                                        }
                                        //Proporcionalidad
                                        VAPC = redondear((x * y) / ((b * c) - (a * (d + x))));
                                        System.out.println("valor de VAPC: " + VAPC);

                                        SFP = redondear(VAPC * SP);
                                        System.out.println("valor de SFP: " + SFP);
                                        VT = redondear(SL + SFP);

                                        txfValorTerreno.setText(Double.toString(VT));

                                    } else {
                                        JOptionPane.showMessageDialog(this, "Complete todos los campos", "Valor de predio", JOptionPane.INFORMATION_MESSAGE);
                                    }
                                    break;
                                case 4://sin acceso por via publica, ni privada
                                    x = Double.parseDouble(txfAncho.getText());
                                    b = Double.parseDouble(txfLargo.getText());
                                    vut = Double.parseDouble(txfValorUnitario.getText());
                                    a = Double.parseDouble(txfAnchoPasaje.getText());
                                    d = Double.parseDouble(txfLargoPasaje.getText());

                                    if (!txfAncho.getText().isEmpty() && !txfLargo.getText().isEmpty()
                                            && !txfAnchoPasaje.getText().isEmpty() && !txfLargoPasaje.getText().isEmpty()
                                            && !txfValorUnitario.getText().isEmpty()) {

                                        if ((a / 3) >= 1) {
                                            SVU = redondear(vut * (1 - (0.01 * d)));
                                        } else {
                                            SVU = redondear(vut * (a / 3) * (1 - (0.01 * d)));
                                        }
                                        System.out.println("SVU es :" + SVU);

                                        if (SVU < 0.5 * vut) {
                                            SVU = redondear(0.5 * vut);
                                        } else {

                                        }
                                        SV1 = redondear(0.8 * SVU);
                                        System.out.println("SV1 es: " + SV1);

                                        //area del lote s
                                        if (b * x > 3 * b * b) {
                                            r1 = redondear(3 * b * b * SV1);
                                            r2 = redondear((Math.abs(r1 - (b * x * SV1))) / 2);

                                            SL = redondear(r1 + r2);
                                            System.out.println("S es : " + SL);
                                        } else {
                                            SL = redondear(b * x * SV1);
                                            System.out.println("S es : " + SL);
                                        }
                                        txfAreaLote.setText(Double.toString(SL));
                                        //valor del pasaje SP
                                        if (a * d > 3 * a * a) {
                                            r1 = redondear(3 * a * a * vut);
                                            r2 = redondear((Math.abs(r1 - (a * d * vut))) / 2);
                                            SP = redondear(r1 + r2);
                                            System.out.println("SP es : " + SP);
                                        } else {
                                            SP = redondear(a * d * vut);
                                            System.out.println("SP es : " + SP);
                                        }

                                        //Proporcionalidad de las areas
                                        SPF = redondear((b * x) / ((b * (x + d)) - (a * d)));
                                        System.out.println("La proporcionalidad es : " + SPF);

                                        SPT = redondear(SPF * SP);
                                        System.out.println("SPT es :" + SPT);
                                        //valor total donde ira?
                                        VT = redondear(SL + SPT);

                                        txfValorTerreno.setText(Double.toString(VT));

                                    } else {
                                        JOptionPane.showMessageDialog(this, "Complete todos los campos", "Valor de predio", JOptionPane.INFORMATION_MESSAGE);

                                    }
                                    break;

                                case 5:// restriccion de uso
                                    b = Double.parseDouble(txfAncho.getText());
                                    d = Double.parseDouble(txfLargo.getText());
                                    vut = Double.parseDouble(txfValorUnitario.getText());
                                    coef = Double.parseDouble(txfCoeficiente.getText());

                                    if (!txfAncho.getText().isEmpty()
                                            && !txfLargo.getText().isEmpty()
                                            && !txfValorUnitario.getText().isEmpty()
                                            && !txfCoeficiente.getText().isEmpty()) {

                                        if (b * d > 3 * b * b) {
                                            s1 = redondear(3 * b * b * vut);
                                            s2 = redondear(Math.abs(s1 - (b * d * vut)) / 2);
                                        } else {
                                            S = redondear(b * d * vut);
                                        }

                                        if (b * d > b * b) {
                                            VT = redondear((s1 + s2) * coef);
                                        } else {
                                            VT = redondear(S * coef);
                                        }

                                        txfValorTerreno.setText(Double.toString(VT));

                                        txfAreaLote.setText(Double.toString(redondear(b * d)));

                                    } else {
                                        JOptionPane.showMessageDialog(this, "Complete todos los campos", "Valor de predio", JOptionPane.INFORMATION_MESSAGE);
                                    }

                                    break;
                                case 6://lote con frente inferior
                                    a = Double.parseDouble(txfAncho.getText());
                                    b = Double.parseDouble(txfLargo.getText());
                                    vut = Double.parseDouble(txfValorUnitario.getText());

                                    if (!txfAncho.getText().isEmpty()
                                            && !txfLargo.getText().isEmpty()
                                            && !txfValorUnitario.getText().isEmpty()) {

                                        if (a * b > 3 * a * a) {
                                            r1 = redondear(3 * a * a * vut);
                                            r2 = redondear(Math.abs(r1 - (a * b * vut)) / 2);
                                            VT = redondear((r1 + r2) * (a / 6));
                                        } else {
                                            r1 = redondear(a * b * vut);
                                            VT = redondear(r1 * (a / 6));
                                        }

                                        txfValorTerreno.setText(Double.toString(VT));

                                        txfAreaLote.setText(Double.toString(redondear(a * b)));

                                    } else {
                                        JOptionPane.showMessageDialog(this, "Complete todos los campos", "Valor de predio", JOptionPane.INFORMATION_MESSAGE);
                                    }

                                    break;
                                case 7:// lote con profundidad
                                    a = Double.parseDouble(txfAncho.getText());
                                    b = Double.parseDouble(txfLargo.getText());
                                    vut = Double.parseDouble(txfValorUnitario.getText());

                                    if (!txfAncho.getText().isEmpty() && !txfLargo.getText().isEmpty()
                                            && !txfValorUnitario.getText().isEmpty()) {
                                        if (a * b > 3 * a * a) {
                                            r1 = redondear(3 * a * a * vut);
                                            r2 = redondear((Math.abs(((3 * a * a - (a * b))) * vut)) / 2);
                                            VT = redondear((r1 + r2) * (b / 15));
                                        } else {
                                            VT = redondear(a * b * vut * (b / 15));
                                        }

                                        txfValorTerreno.setText(Double.toString(VT));

                                        txfAreaLote.setText(Double.toString(redondear(b * a)));

                                    } else {
                                        JOptionPane.showMessageDialog(this, "Complete todos los campos", "Valor de predio", JOptionPane.INFORMATION_MESSAGE);
                                    }

                                    break;
                                case 8:/// parte en tierra firme
                                    a = Double.parseDouble(txfAncho.getText());
                                    b = Double.parseDouble(txfLargo.getText());
                                    vut = Double.parseDouble(txfValorUnitario.getText());
                                    if (!txfAncho.getText().isEmpty()
                                            && !txfLargo.getText().isEmpty()
                                            && !txfValorUnitario.getText().isEmpty()) {
                                        if (a * b > 3 * a * a) {
                                            r1 = redondear(3 * a * a * vut);
                                            r2 = redondear((Math.abs((a * b) - (3 * a * a)) * vut) / 2);
                                            VT = redondear(r1 + r2);
                                            System.out.println("r1 " + r1);
                                            System.out.println("r2 " + r2);
                                        } else {
                                            VT = redondear(a * b * vut);
                                        }

                                        txfValorTerreno.setText(Double.toString(VT));

                                        txfAreaLote.setText(Double.toString(redondear(b * a)));

                                    } else {
                                        JOptionPane.showMessageDialog(this, "Complete todos los campos", "Valor de predio", JOptionPane.INFORMATION_MESSAGE);
                                    }
                                    break;
                            }
                        }
                        break;

                }
            }
//     
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Error en la operación :" + e, "Valor de predio", JOptionPane.INFORMATION_MESSAGE);

        }

    }//GEN-LAST:event_jbCalcularValorTotalActionPerformed

    private void jbAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbAgregarActionPerformed
        // TODO add your handling code here:


    }//GEN-LAST:event_jbAgregarActionPerformed

    private void jbGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbGuardarActionPerformed
        // TODO add your handling code here:


    }//GEN-LAST:event_jbGuardarActionPerformed

    private void txfValorTerrenoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txfValorTerrenoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txfValorTerrenoActionPerformed

    private void txfNumLadosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txfNumLadosActionPerformed

        // jtLado.setModel(modeloLado);  
        int cantidad;
        List<BELado> lista;

        if (!txfNumLados.getText().isEmpty()) {
            lista = new ArrayList<>();
            cantidad = Integer.parseInt(txfNumLados.getText());
            //modeloLado.clear();
            char bandera = 'a';
            for (char i = 0; i < cantidad; i++) {
                beLado = new BELado();
                beLado.setNombre(Character.toString(bandera));
                beLado.setMedida(0.0);
                beLado.setValorunitario(0.0);
                lista.add(beLado);
                bandera++;
            }

            modeloLado = new ModeloLado(lista);
            jtLado.setModel(modeloLado);
            for (int i = 0; i < lista.size(); i++) {
                modeloLado.add(lista.get(i));
            }
        }


    }//GEN-LAST:event_txfNumLadosActionPerformed

    private void jcbTipoValuacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbTipoValuacionActionPerformed
        // TODO add your handling code here:
        clear();
        jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_default.png")));

        if (_OPERACION != _DESCONOCIDO) {
            switch (jcbTipoValuacion.getSelectedIndex()) {
                case 1: //comercial

                    jbCalcularValorTotal.setEnabled(true);
                    txfValorUnitario.setEnabled(true);
                    txfAreaLote.setEnabled(true);
                    jcbConsiderar.setEnabled(true);

                    jcbTipoTerreno.setEnabled(false);
                    txfAncho.setEnabled(false);
                    txfLargo.setEnabled(false);
                    txfCoeficiente.setEnabled(false);
                    jcbCaracteristicaTerreno.setEnabled(false);
                    txfAnchoPasaje.setEnabled(false);
                    txfLargoPasaje.setEnabled(false);
                    txfNumLados.setEnabled(false);
                    txfAnchoPasadizo.setEnabled(false);
                    txfDistancia.setEnabled(false);
                    txfAnchoDominio.setEnabled(false);
                    txfLargoDominio.setEnabled(false);

                    jtLado.setEnabled(false);
                    jlAncho.setText("");
                    jlLargo.setText("");
                    jlAnchoDominio.setText("");
                    jlAnchoPasadizo.setText("");
                    jlAnchoPasaje.setText("");
                    jlArea.setText("");
                    jlCoeficiente.setText("");
                    jlDistancia.setText("");
                    jlLargoPasaje.setText("");
                    jlLargoDominio.setText("");
                    jlValorUnitario.setText("");

                    break;
                case 2: // reglamentaria
                    jcbTipoTerreno.setEnabled(true);
                    txfAncho.setEnabled(false);
                    txfLargo.setEnabled(false);
                    txfValorUnitario.setEnabled(true);

                    txfCoeficiente.setEnabled(false);
                    jcbConsiderar.setEnabled(false);
                    txfAreaLote.setEnabled(false);
                    jcbCaracteristicaTerreno.setEnabled(false);
                    txfAnchoPasaje.setEnabled(false);
                    txfLargoPasaje.setEnabled(false);
                    txfNumLados.setEnabled(false);
                    txfAnchoPasadizo.setEnabled(false);
                    txfDistancia.setEnabled(false);
                    txfAnchoDominio.setEnabled(false);
                    txfLargoDominio.setEnabled(false);
                    jtLado.setEnabled(false);
                    jlAncho.setText("");
                    jlLargo.setText("");
                    jlAnchoDominio.setText("");
                    jlAnchoPasadizo.setText("");
                    jlAnchoPasaje.setText("");
                    jlArea.setText("");
                    jlCoeficiente.setText("");
                    jlDistancia.setText("");
                    jlLargoPasaje.setText("");
                    jlLargoDominio.setText("");
                    jlValorUnitario.setText("");

                    break;
            }
        }
    }//GEN-LAST:event_jcbTipoValuacionActionPerformed

    private void jcbConsiderarPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jcbConsiderarPropertyChange
        // TODO add your handling code here:
        if (jcbConsiderar.isSelected()) {
            txfPorcentajeDerecho.setEnabled(true);
            txfPorcentajeDerecho.setEditable(true);
        } else {
            txfPorcentajeDerecho.setText("");
            txfPorcentajeDerecho.setEnabled(false);
        }
    }//GEN-LAST:event_jcbConsiderarPropertyChange

    private void txfAnchoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txfAnchoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txfAnchoActionPerformed

    private void jcbConsiderarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbConsiderarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jcbConsiderarActionPerformed

    private void txfValorUnitarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txfValorUnitarioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txfValorUnitarioActionPerformed

    private void txfNumLadosKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txfNumLadosKeyTyped

    }//GEN-LAST:event_txfNumLadosKeyTyped


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JButton jbAgregar;
    private javax.swing.JButton jbCalcularValorTotal;
    private javax.swing.JButton jbCancelar;
    private javax.swing.JButton jbGuardar;
    private javax.swing.JButton jbSalir;
    private javax.swing.JComboBox jcbCaracteristicaTerreno;
    private javax.swing.JCheckBox jcbConsiderar;
    private javax.swing.JComboBox jcbTipoTerreno;
    private javax.swing.JComboBox jcbTipoValuacion;
    private javax.swing.JLabel jlAncho;
    private javax.swing.JLabel jlAnchoDominio;
    private javax.swing.JLabel jlAnchoPasadizo;
    private javax.swing.JLabel jlAnchoPasaje;
    private javax.swing.JLabel jlArea;
    private javax.swing.JLabel jlCoeficiente;
    private javax.swing.JLabel jlDistancia;
    private javax.swing.JLabel jlImagen;
    private javax.swing.JLabel jlLargo;
    private javax.swing.JLabel jlLargoDominio;
    private javax.swing.JLabel jlLargoPasaje;
    private javax.swing.JLabel jlValorUnitario;
    private javax.swing.JTable jtLado;
    private javax.swing.JTextField txfAncho;
    private javax.swing.JTextField txfAnchoDominio;
    javax.swing.JTextField txfAnchoPasadizo;
    private javax.swing.JTextField txfAnchoPasaje;
    private javax.swing.JTextField txfAreaLote;
    private javax.swing.JTextField txfCoeficiente;
    private javax.swing.JTextField txfDistancia;
    private javax.swing.JTextField txfLargo;
    private javax.swing.JTextField txfLargoDominio;
    private javax.swing.JTextField txfLargoPasaje;
    private javax.swing.JTextField txfNumLados;
    private javax.swing.JTextField txfPorcentajeDerecho;
    private javax.swing.JTextField txfValorTerreno;
    private javax.swing.JTextField txfValorUnitario;
    // End of variables declaration//GEN-END:variables

    @Override
    public void _cargarCombos() throws Exception {

    }

    @Override
    public void _agregaValidadoresControl() {
        //addEnterDoclickEvent(new Object[][]{{txfBuscar, jbBuscar}});
        _addOperationEventsButtons(jbAgregar, jbGuardar, jbCancelar);
        //  _addRestoreDataEventsTable(jtTerreno);
        // _addSearchEventsButton(jbBuscar);
        addCharacterValidatorEvent(new Object[][]{ //   
            {txfPorcentajeDerecho, Utilitarios.NUMERICO_REAL, 160},
            {txfValorUnitario, Utilitarios.NUMERICO_REAL, 160},
            {txfAncho, Utilitarios.NUMERICO_REAL, 160},
            {txfLargo, Utilitarios.NUMERICO_REAL, 160},
            {txfAreaLote, Utilitarios.NUMERICO_REAL, 160},
            {txfNumLados, Utilitarios.NUMERICO, 160},
            {txfAnchoPasadizo, Utilitarios.NUMERICO_REAL, 160},
            {txfDistancia, Utilitarios.NUMERICO_REAL, 160},
            {txfAnchoPasaje, Utilitarios.NUMERICO_REAL, 160},
            {txfLargoPasaje, Utilitarios.NUMERICO_REAL, 160},
            {txfAnchoDominio, Utilitarios.NUMERICO_REAL, 160},
            {txfLargoDominio, Utilitarios.NUMERICO_REAL, 160},
            {txfCoeficiente, Utilitarios.NUMERICO_REAL, 20}

        });

    }

    @Override
    public boolean _isDatosValidosBE() {
        return isDatosLlenos(new Object[][]{
            {txfValorTerreno, "Calcular el valor de terrno."},
            {jcbTipoValuacion, "Seleccionar el tipo de valuación."}
        });
    }

    @Override
    public int _registrarBE() throws Exception {
        try {

            be = new BETerreno();

            be.setTipolote(jcbTipoTerreno.getSelectedItem().toString());
            be.setValortotal(Double.parseDouble(txfValorTerreno.getText()));
            be.setTipovaluacion(jcbTipoValuacion.getSelectedItem().toString());

            if (jcbConsiderar.isSelected()) {
                be.setPorcentajeDerecho(Double.parseDouble(txfPorcentajeDerecho.getText()));
            } else {
                be.setPorcentajeDerecho(0);
            }

            if (jcbTipoValuacion.getSelectedIndex() == 1) {
                be.setArea(Double.parseDouble(txfAreaLote.getText()));
                be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));
            }

            if (jcbTipoTerreno.getSelectedIndex() == 1) {// un solo frente

                if (jcbCaracteristicaTerreno.getSelectedIndex() == 1) {//rectangular
                    be.setAncho(Double.parseDouble(txfAncho.getText()));
                    be.setLargo(Double.parseDouble(txfLargo.getText()));
                    be.setArea(Double.parseDouble(txfAreaLote.getText()));
                    be.setCaracteristicalote(jcbCaracteristicaTerreno.getSelectedItem().toString());

                } else if (jcbCaracteristicaTerreno.getSelectedIndex() == 2) {// irregular
                    be.setAncho(0.0);
                    be.setLargo(0.0);
                    be.setArea(Double.parseDouble(txfAreaLote.getText()));
                    be.setCaracteristicalote(jcbCaracteristicaTerreno.getSelectedItem().toString());
                }

                be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));
                be.setNumlados(0);
                be.setAnchopasadizo(0.0);
                be.setDistanciapasadizo(0.0);
                be.setAnchodominio(0.0);
                be.setLargodominio(0.0);
                be.setCoeficiente(0.0);
                be.setLargopasaje(0.0);
                be.setAnchopasaje(0.0);

            } else if (jcbTipoTerreno.getSelectedIndex() == 2) {// mas de un frente
                be.setNumlados(Integer.parseInt(txfNumLados.getText()));

                be.setCaracteristicalote("");
                be.setAncho(0.0);
                be.setLargo(0.0);
                be.setArea(Double.parseDouble(txfAreaLote.getText()));
                be.setValorunitario(0.0);
                be.setAnchopasadizo(0.0);
                be.setDistanciapasadizo(0.0);
                be.setAnchodominio(0.0);
                be.setLargodominio(0.0);
                be.setCoeficiente(0.0);
                be.setLargopasaje(0.0);
                be.setAnchopasaje(0.0);

            } else if (jcbTipoTerreno.getSelectedIndex() == 3) {//frente a un pasadizo

                be.setAncho(Double.parseDouble(txfAncho.getText()));
                be.setLargo(Double.parseDouble(txfLargo.getText()));
                be.setAnchopasadizo(Double.parseDouble(txfAnchoPasadizo.getText()));
                be.setDistanciapasadizo(Double.parseDouble(txfDistancia.getText()));
                be.setAnchodominio(Double.parseDouble(txfAnchoDominio.getText()));
                be.setLargodominio(Double.parseDouble(txfLargoDominio.getText()));
                be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

                be.setCaracteristicalote("");
                be.setArea(Double.parseDouble(txfAreaLote.getText()));
                be.setCoeficiente(0.0);
                be.setLargopasaje(0.0);
                be.setAnchopasaje(0.0);
                be.setNumlados(0);

            } else if (jcbTipoTerreno.getSelectedIndex() == 4) {///sin acceso por cia publica

                be.setAncho(Double.parseDouble(txfAncho.getText()));
                be.setLargo(Double.parseDouble(txfLargo.getText()));
                be.setLargopasaje(Double.parseDouble(txfLargoPasaje.getText()));
                be.setAnchopasaje(Double.parseDouble(txfAnchoPasaje.getText()));
                be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

                be.setCaracteristicalote("");
                be.setArea(Double.parseDouble(txfAreaLote.getText()));
                be.setAnchopasadizo(0.0);
                be.setDistanciapasadizo(0.0);
                be.setAnchodominio(0.0);
                be.setLargodominio(0.0);
                be.setCoeficiente(0.0);
                be.setNumlados(0);
            } else if (jcbTipoTerreno.getSelectedIndex() == 5) {//restriccion de uso

                be.setAncho(Double.parseDouble(txfAncho.getText()));
                be.setLargo(Double.parseDouble(txfLargo.getText()));
                be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));
                be.setCoeficiente(Double.parseDouble(txfCoeficiente.getText()));

                be.setCaracteristicalote("");
                be.setArea(Double.parseDouble(txfAreaLote.getText()));
                be.setAnchopasadizo(0.0);
                be.setDistanciapasadizo(0.0);
                be.setAnchodominio(0.0);
                be.setLargodominio(0.0);
                be.setLargopasaje(0.0);
                be.setAnchopasaje(0.0);
                be.setNumlados(0);

            } else if (jcbTipoTerreno.getSelectedIndex() == 6) {//lote con frente inferior
                be.setAncho(Double.parseDouble(txfAncho.getText()));
                be.setLargo(Double.parseDouble(txfLargo.getText()));
                be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

                be.setCaracteristicalote("");
                be.setArea(Double.parseDouble(txfAreaLote.getText()));
                be.setAnchopasadizo(0.0);
                be.setDistanciapasadizo(0.0);
                be.setAnchodominio(0.0);
                be.setLargodominio(0.0);
                be.setLargopasaje(0.0);
                be.setAnchopasaje(0.0);
                be.setNumlados(0);
                be.setCoeficiente(0.0);

            } else if (jcbTipoTerreno.getSelectedIndex() == 7) {//lote con profundidad
                be.setAncho(Double.parseDouble(txfAncho.getText()));
                be.setLargo(Double.parseDouble(txfLargo.getText()));
                be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

                be.setCaracteristicalote("");
                be.setArea(Double.parseDouble(txfAreaLote.getText()));
                be.setAnchopasadizo(0.0);
                be.setDistanciapasadizo(0.0);
                be.setAnchodominio(0.0);
                be.setLargodominio(0.0);
                be.setLargopasaje(0.0);
                be.setAnchopasaje(0.0);
                be.setNumlados(0);
                be.setCoeficiente(0.0);
            } else if (jcbTipoTerreno.getSelectedIndex() == 8) {// parte en tierra firme
                be.setAncho(Double.parseDouble(txfAncho.getText()));
                be.setLargo(Double.parseDouble(txfLargo.getText()));
                be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

                be.setCaracteristicalote("");
                be.setArea(Double.parseDouble(txfAreaLote.getText()));
                be.setAnchopasadizo(0.0);
                be.setDistanciapasadizo(0.0);
                be.setAnchodominio(0.0);
                be.setLargodominio(0.0);
                be.setLargopasaje(0.0);
                be.setAnchopasaje(0.0);
                be.setNumlados(0);
                be.setCoeficiente(0.0);
            }

            int idte1 = bl.obtenerUltimoId();

            int id = bl.registrar(be);

            int idte = bl.obtenerUltimoId();

            //guardar lado
            if (jcbTipoTerreno.getSelectedIndex() == 2 && idte1 != idte) {

                for (BELado s : modeloLado.getList()) {
                    beLado = new BELado();
                    beLado.setNombre(s.getNombre());
                    beLado.setMedida(s.getMedida());
                    beLado.setValorunitario(s.getValorunitario());
                    beLado.setTerrenoid(idte);
                    blLado.registrar(beLado);
                }
            }

            JOptionPane.showMessageDialog(this, "El valor del terreno fue calculado satisfactoriamente.", "Aviso", JOptionPane.INFORMATION_MESSAGE);
            cargar();
            dispose();
            _resetControls();
            _deshabilitarControlesDatos();
            _listarBEs();

            return id;

        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Error al valorizar el terreno.", "Aviso", JOptionPane.INFORMATION_MESSAGE);
            return -1;
        }
    }

    @Override
    public int _guardarCambiosBE() throws Exception {

        be.setTipolote(jcbTipoTerreno.getSelectedItem().toString());
        be.setValortotal(Double.parseDouble(txfValorTerreno.getText()));
        be.setTipovaluacion(jcbTipoValuacion.getSelectedItem().toString());
        if (jcbConsiderar.isSelected()) {
            be.setPorcentajeDerecho(Double.parseDouble(txfPorcentajeDerecho.getText()));
        } else {
            be.setPorcentajeDerecho(0);
        }

        if (jcbTipoTerreno.getSelectedIndex() == 1) {// un solo frente

            be.setCaracteristicalote(jcbCaracteristicaTerreno.getSelectedItem().toString());
            be.setAncho(Double.parseDouble(txfAncho.getText()));
            be.setLargo(Double.parseDouble(txfLargo.getText()));
            be.setArea(Double.parseDouble(txfAreaLote.getText()));
            be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

            be.setNumlados(0);
            be.setAnchopasadizo(0.0);
            be.setDistanciapasadizo(0.0);
            be.setAnchodominio(0.0);
            be.setLargodominio(0.0);
            be.setCoeficiente(0.0);
            be.setLargopasaje(0.0);
            be.setAnchopasaje(0.0);

        } else if (jcbTipoTerreno.getSelectedIndex() == 2) {// mas de un frente
            be.setNumlados(Integer.parseInt(txfNumLados.getText()));

            be.setCaracteristicalote("");
            be.setAncho(0.0);
            be.setLargo(0.0);
            be.setArea(Double.parseDouble(txfAreaLote.getText()));
            be.setValorunitario(0.0);
            be.setAnchopasadizo(0.0);
            be.setDistanciapasadizo(0.0);
            be.setAnchodominio(0.0);
            be.setLargodominio(0.0);
            be.setCoeficiente(0.0);
            be.setLargopasaje(0.0);
            be.setAnchopasaje(0.0);

        } else if (jcbTipoTerreno.getSelectedIndex() == 3) {//frente a un pasadizo

            be.setAncho(Double.parseDouble(txfAncho.getText()));
            be.setLargo(Double.parseDouble(txfLargo.getText()));
            be.setAnchopasadizo(Double.parseDouble(txfAnchoPasadizo.getText()));
            be.setDistanciapasadizo(Double.parseDouble(txfDistancia.getText()));
            be.setAnchodominio(Double.parseDouble(txfAnchoDominio.getText()));
            be.setLargodominio(Double.parseDouble(txfLargoDominio.getText()));
            be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

            be.setCaracteristicalote("");
            be.setArea(Double.parseDouble(txfAreaLote.getText()));
            be.setCoeficiente(0.0);
            be.setLargopasaje(0.0);
            be.setAnchopasaje(0.0);
            be.setNumlados(0);

        } else if (jcbTipoTerreno.getSelectedIndex() == 4) {///sin acceso por cia publica

            be.setAncho(Double.parseDouble(txfAncho.getText()));
            be.setLargo(Double.parseDouble(txfLargo.getText()));
            be.setLargopasaje(Double.parseDouble(txfLargoPasaje.getText()));
            be.setAnchopasaje(Double.parseDouble(txfAnchoPasaje.getText()));
            be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

            be.setCaracteristicalote("");
            be.setArea(Double.parseDouble(txfAreaLote.getText()));
            be.setAnchopasadizo(0.0);
            be.setDistanciapasadizo(0.0);
            be.setAnchodominio(0.0);
            be.setLargodominio(0.0);
            be.setCoeficiente(0.0);
            be.setNumlados(0);
        } else if (jcbTipoTerreno.getSelectedIndex() == 5) {//restriccion de uso

            be.setAncho(Double.parseDouble(txfAncho.getText()));
            be.setLargo(Double.parseDouble(txfLargo.getText()));
            be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));
            be.setCoeficiente(Double.parseDouble(txfCoeficiente.getText()));

            be.setCaracteristicalote("");
            be.setArea(Double.parseDouble(txfAreaLote.getText()));
            be.setAnchopasadizo(0.0);
            be.setDistanciapasadizo(0.0);
            be.setAnchodominio(0.0);
            be.setLargodominio(0.0);
            be.setLargopasaje(0.0);
            be.setAnchopasaje(0.0);
            be.setNumlados(0);

        } else if (jcbTipoTerreno.getSelectedIndex() == 6) {//lote con frente inferior
            be.setAncho(Double.parseDouble(txfAncho.getText()));
            be.setLargo(Double.parseDouble(txfLargo.getText()));
            be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

            be.setCaracteristicalote("");
            be.setArea(Double.parseDouble(txfAreaLote.getText()));
            be.setAnchopasadizo(0.0);
            be.setDistanciapasadizo(0.0);
            be.setAnchodominio(0.0);
            be.setLargodominio(0.0);
            be.setLargopasaje(0.0);
            be.setAnchopasaje(0.0);
            be.setNumlados(0);
            be.setCoeficiente(0.0);

        } else if (jcbTipoTerreno.getSelectedIndex() == 7) {//lote con profundidad
            be.setAncho(Double.parseDouble(txfAncho.getText()));
            be.setLargo(Double.parseDouble(txfLargo.getText()));
            be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

            be.setCaracteristicalote("");
            be.setArea(Double.parseDouble(txfAreaLote.getText()));
            be.setAnchopasadizo(0.0);
            be.setDistanciapasadizo(0.0);
            be.setAnchodominio(0.0);
            be.setLargodominio(0.0);
            be.setLargopasaje(0.0);
            be.setAnchopasaje(0.0);
            be.setNumlados(0);
            be.setCoeficiente(0.0);
        } else if (jcbTipoTerreno.getSelectedIndex() == 8) {// parte en tierra firme
            be.setAncho(Double.parseDouble(txfAncho.getText()));
            be.setLargo(Double.parseDouble(txfLargo.getText()));
            be.setValorunitario(Double.parseDouble(txfValorUnitario.getText()));

            be.setCaracteristicalote("");
            be.setArea(Double.parseDouble(txfAreaLote.getText()));
            be.setAnchopasadizo(0.0);
            be.setDistanciapasadizo(0.0);
            be.setAnchodominio(0.0);
            be.setLargodominio(0.0);
            be.setLargopasaje(0.0);
            be.setAnchopasaje(0.0);
            be.setNumlados(0);
            be.setCoeficiente(0.0);
        }

        int rsp = bl.actualizarRegistro(be);
        _resetControls();
        _deshabilitarControlesDatos();
        _listarBEs();
        return rsp;
    }

    @Override
    public void _listarBEs() throws Exception {
    }

    @Override
    public void _recuperarDatosBE() throws Exception {

    }

    @Override
    public void _deshabilitarControlesDatos() {
        disableComponent(new Object[]{
            jcbTipoTerreno, jcbCaracteristicaTerreno, txfAncho, txfLargo, txfAreaLote,
            txfValorUnitario, txfNumLados, txfAnchoPasadizo, txfDistancia, txfAnchoDominio, txfLargoDominio,
            txfCoeficiente, txfLargoPasaje, txfAnchoPasaje, txfValorTerreno, jbCalcularValorTotal, jcbTipoValuacion,
            jcbTipoValuacion, jtLado, txfPorcentajeDerecho});
        jtLado.setOpaque(true);
    }

    @Override
    public void _habilitarControlesDatos() {
        enableComponent(new Object[]{
            jcbTipoTerreno, jcbCaracteristicaTerreno, txfAncho, txfLargo, txfAreaLote,
            txfValorUnitario, txfNumLados, txfAnchoPasadizo, txfDistancia, txfAnchoDominio,
            txfLargoDominio, txfCoeficiente, txfLargoPasaje, txfAnchoPasaje,
            txfValorTerreno, jcbTipoValuacion, jcbTipoValuacion, jtLado, txfPorcentajeDerecho});
        txfValorTerreno.setEnabled(false);
        txfPorcentajeDerecho.setEnabled(false);
        jtLado.setOpaque(true);
        txfAncho.setEnabled(false);
        txfLargo.setEnabled(false);
        txfAreaLote.setEnabled(false);
        txfNumLados.setEnabled(false);
        txfAnchoPasadizo.setEnabled(false);
        txfDistancia.setEnabled(false);
        txfAnchoDominio.setEnabled(false);
        txfLargoDominio.setEnabled(false);
        txfCoeficiente.setEnabled(false);
        txfLargoPasaje.setEnabled(false);
        txfAnchoPasaje.setEnabled(false);
        jcbConsiderar.setEnabled(false);

    }

    @Override
    public void _resetControls() {
        resetComponents(new Object[]{
            jcbTipoTerreno, jcbCaracteristicaTerreno, txfAncho, txfLargo, txfAreaLote,
            txfValorUnitario, txfNumLados, txfAnchoPasadizo, txfDistancia, txfAnchoDominio, txfLargoDominio,
            txfCoeficiente, txfLargoPasaje, txfAnchoPasaje, txfValorTerreno, jcbTipoValuacion,
            jcbTipoValuacion, txfPorcentajeDerecho});
        txfValorTerreno.setEnabled(false);
        txfPorcentajeDerecho.setEnabled(false);
        modeloLado.clear();
        jlImagen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ing/sisval/imagen/t_default.png")));
        jlAncho.setText("");
        jlLargo.setText("");
        jlAnchoDominio.setText("");
        jlAnchoPasadizo.setText("");
        jlAnchoPasaje.setText("");
        jlArea.setText("");
        jlCoeficiente.setText("");
        jlDistancia.setText("");
        jlLargoPasaje.setText("");
        jlLargoDominio.setText("");
        jlValorUnitario.setText("");
        jtLado.setOpaque(true);
        jcbConsiderar.setSelected(false);
        txfValorTerreno.setEnabled(false);
        txfPorcentajeDerecho.setEnabled(false);
        jtLado.setOpaque(true);
        txfAncho.setEnabled(false);
        txfLargo.setEnabled(false);
        txfAreaLote.setEnabled(false);
        txfNumLados.setEnabled(false);
        txfAnchoPasadizo.setEnabled(false);
        txfDistancia.setEnabled(false);
        txfAnchoDominio.setEnabled(false);
        txfLargoDominio.setEnabled(false);
        txfCoeficiente.setEnabled(false);
        txfLargoPasaje.setEnabled(false);
        txfAnchoPasaje.setEnabled(false);
        jcbConsiderar.setEnabled(false);

    }

    public void cargar() {
        BETerreno bet;
        try {
            bet = bl.buscar(bl.obtenerUltimoId());
            System.out.println("Este es el id de terreno: " + bl.obtenerUltimoId());

            System.out.println("Esta esta en el la valuacion1");
            parent.administrarPropiedad.agregarTerreno(bet);

            System.out.println("Este es el id en bet: " + bet.getTerrenoid());
        } catch (Exception ex) {
            Logger.getLogger(JIFValuacionTerreno.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void clear() {
        txfAncho.setText("");
        txfAnchoDominio.setText("");
        txfAnchoPasadizo.setText("");
        txfAnchoPasaje.setText("");
        txfAreaLote.setText("");
        txfCoeficiente.setText("");
        txfCoeficiente.setText("");
        txfDistancia.setText("");
        txfLargo.setText("");
        txfLargoDominio.setText("");
        txfLargoPasaje.setText("");
        txfNumLados.setText("");
        txfPorcentajeDerecho.setText("");
        txfValorTerreno.setText("");
        txfValorUnitario.setText("");
    }

    public double redondear(double numero) {
        BigDecimal big = new BigDecimal(numero);
        big = big.setScale(2, RoundingMode.HALF_UP);
        System.out.println("Este es el valor redondeado :" + new Double(big.toString()));
        return new Double(big.toString());
    }

}
